"""
遍历列表，取出表内的偶数，存入到一个新的列表对象中
while和for各来一次
"""
list_demo = [1,2,3,4,5,6,7,8,9,10]

def while_getdouble():
    index=0
    list_demo02=[]
    while index<len(list_demo):
        if list_demo[index]%2==0:
            list_demo02.append(list_demo[index])
        index+=1
    print(list_demo02)
while_getdouble()

def for_getdouble():
    index=0
    list_demo02=[]
    for x in list_demo:
        if x%2==0:
            list_demo02.append(x)
    print(list_demo02)
for_getdouble()